package android.demo.engine.tasks;

import android.demo.engine.tasks.hardcoded.HardCodedActivityBrowserTask;
import android.demo.engine.tasks.hardcoded.HardCodedActivityTask;
import android.demo.engine.tasks.hardcoded.HardCodedServiceBinderTask;

public class TaskFactory {

	private static TaskFactory instance;
	/**
	 * 
	 * hardcoded, not definitive version,
	 * we assume that task's Id is equal to its index in the TASK_LIST array
	 * 
	 */
	
	public static final int LOAN_TASK =0;
	public static final int SERVICE_TASK =1;
	public static final int BROWSER_TASK=2;
	public static final int RETURN_TASK =3;
	
	private TaskFactory(){};
	
	public Task[] getTasks(){
		HardCodedActivityTask makeLoan = new HardCodedActivityTask(LOAN_TASK);
		HardCodedServiceBinderTask loanService = new HardCodedServiceBinderTask(SERVICE_TASK);
		HardCodedActivityBrowserTask browserTask= new HardCodedActivityBrowserTask(BROWSER_TASK);
		HardCodedActivityTask handleReturn = new HardCodedActivityTask(RETURN_TASK);
		handleReturn.addServiceToBeCompleted(loanService);
		return new Task[]{makeLoan,loanService,browserTask,handleReturn};
	}
	public static TaskFactory getInstance() {
		if(instance==null)
			instance= new TaskFactory();
		return instance;
	}
}
